﻿using System;
using System.Windows;

/*
Copyright 2011 Mirosław M. Mączka

This file is part of MyChars.

    Flac2Wma is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    Foobar is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/
namespace MyChars
{
    public partial class MainWindow : Window
    {
        private void SetLocalizedTexts()
        {
            if (System.Globalization.CultureInfo.CurrentCulture.TextInfo.CultureName.StartsWith("PL", StringComparison.CurrentCultureIgnoreCase))
            {
                fileMenuItem.Header = (string)FindResource("fileMenuItem_PL");
                topmostConfigurationFileMenuItem.Header = (string)FindResource("topmostConfigurationFileMenuItem_PL");
                editConfigurationFileMenuItem.Header = (string)FindResource("editConfigurationFileMenuItem_PL");
                writeCleanConfigFileMenuItem.Header = (string)FindResource("writeCleanConfigFileMenuItem_PL");
                exitToolStripMenuItem.Header = (string)FindResource("exitToolStripMenuItem_PL");
            }
        }

        public static object GetLocalizedResource(string name)
        {
            string [] ss = System.Globalization.CultureInfo.CurrentCulture.TextInfo.CultureName.Split(new []{'-'});
            object o;
            FrameworkElement fe = ((FrameworkElement)Application.Current.MainWindow);
            if(null != (o = fe.TryFindResource((object)(name + "_" + ss[0].ToUpper()))))
            {
                return o;
            }
            return fe.FindResource((object)name);
        }
    }//class
}//namespace
